/*
 *  Class name: ChooseableTeamListItem.java
 *  Version: 1.0
 *  Date: 11.12.2013
 */
package cz.muni.fi.pa165.soccergamesarchive.restclient.gui.components.pageablelist.items.entity;

import cz.muni.fi.pa165.soccergamesarchive.businesslayer.dtos.TeamDTO;
import cz.muni.fi.pa165.soccergamesarchive.restclient.gui.components.pageablelist.PageableListPanel;
import cz.muni.fi.pa165.soccergamesarchive.restclient.gui.components.pageablelist.items.PageableListItemButton;
import java.awt.event.MouseEvent;
import javax.swing.ImageIcon;

/**
 *
 * @author Michal Ďuriš
 */
public class ChooseableTeamListItem extends PageableListItemButton<TeamDTO> {

    private static final long serialVersionUID = 1L;

    public ChooseableTeamListItem(PageableListPanel<TeamDTO> parentList,
                                  TeamDTO entity) {
        super(parentList, entity);
    }

    @Override
    public void init() {
        setIcon(new ImageIcon(getClass().getResource(
                "/icons/components/team-icon.png")));
    }

    @Override
    public void setEntity(TeamDTO entity) {
        this.entity.setId(entity.getId());
        this.entity.setName(entity.getName());
        this.entity.setManagerName(entity.getManagerName());
        this.entity.setPlayers(entity.getPlayers());
    }

    @Override
    public String getEntityText() {
        return "<html> Name: " + entity.getName()
                + " <br> Manager name: " + entity.getManagerName();
    }

    @Override
    public void mouseClicked(MouseEvent e) {

        if (selectedItem) {

            unselectItem();
            parentList.setSelectedItem(null);
        } else {

            selectItem();
            parentList.setSelectedItem(this);
        }
    }

    @Override
    public void mousePressed(MouseEvent e) {
    }

    @Override
    public void mouseReleased(MouseEvent e) {
    }

    @Override
    public void mouseEntered(MouseEvent e) {
    }

    @Override
    public void mouseExited(MouseEvent e) {
    }

}
